package com.android.job.ui.adapter;

import java.util.ArrayList;
import java.util.List;

import com.android.job.model.Job;
import com.android.job.ui.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
/**
 * 职位查询结果列表的Adapter
 * @author yyl
 *
 */
public class JobListAdapter extends BaseAdapter{
	private Context mContext;
	private List<Job> jobList;
	private ViewHolder holder;
	
	
	
	
	public JobListAdapter(Context mContext, ArrayList<Job> jobList) {
		super();
		this.mContext = mContext;
		this.jobList = jobList;
	}

	@Override
	public int getCount() {
		return jobList.size();
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView == null){
			holder = new ViewHolder();
			convertView = LayoutInflater.from(mContext).inflate(R.layout.job_item, null);
			holder.name = (TextView) convertView.findViewById(R.id.company_name_tv_id);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder) convertView.getTag();
		}
		holder.name.setText(jobList.get(position).getCompanyName());
		return convertView;
	}

	
	private class ViewHolder
	{
		/**
		 * 公司名称
		 */
		private TextView name;

	}
}
